﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DAL;
using Model;
using IDAL;
using BLL;
/***************************
 * API
 * 用户
 * Author：JXL
 ***************************/ 
namespace EstateService.Controllers
{
    public class UsersController : ApiController
    {
        BLL.IFactory<IUsersDAL, UsersDAL> bll = new Factory<IUsersDAL, UsersDAL>();



       
        // GET api/users
        /// <summary>
        /// 根据账户和密码来查询所有信息
        /// </summary>
        /// <param name="mo"></param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("useLogin")]
        public Users UsersLogin([FromUri]Users mo)
        {

         return   bll.Fbi().UsersLogin(mo);
 
        }

        /// <summary>
        /// 显示所有人员的信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("UsersShow")]
        public List<Users> UsersShow()
        {
            return bll.Fbi().UsersShow();
        }

        [HttpPost]
        [ActionName("UsersFull")]
        public int UsersFull(int id)
        {
            return bll.Fbi().UsersFull(id);
        }

        [HttpPost]
        [ActionName("UsersStop")]
        public int UsersStop(int id)
        {

            return bll.Fbi().UsersStop(id);
        }

        [HttpPost]
        [ActionName("UsersDel")]
        public int UsersDel(int id)
        {
            return bll.Fbi().UsersDel(id); 
        }

        [HttpGet]
        [ActionName("UsersLike")]
        public List<Users> UsersDel(string name)
        {
         return  bll.Fbi().UsersShow().Where(a => a.users_Name.Contains(name)).ToList();
        }
        [HttpGet]
        [ActionName("UsersCount")]
        public int UsersCount()
        {
             return bll.Fbi().UsersShow().Count();
        }

        [HttpPost]
        [ActionName("UsersSelectId")]
        public List<Users> UsersSelectId(int id)
        {
            return bll.Fbi().UsersSelectId(id);
        }

        [HttpPost]
        [ActionName("UsereUpt")]
        public int UsereUpt(Users mo)
        {
            return bll.Fbi().UsereUpt(mo);
        }






        // GET api/users/5
        public List<Users> Get(int id)
        {
            return bll.Fbi().GetUsers(id);
        }

        // POST api/users
        public void Post([FromBody]string value)
        {
        }

        // PUT api/users/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/users/5
        public void Delete(int id)
        {
        }
    }
}
